

package CtrLayer;
import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;
/**
 */
public class CtrSupplier {


    /** Creates a new instance of CtrCostumer */
    public CtrSupplier() {

    }
    public ArrayList findAllSuppliers()
    {
      IFDBSupplier dbSupplier = new DBSupplier();
      ArrayList allSup = new ArrayList();
      allSup = dbSupplier.getAllSuppliers(false);
      return allSup;
    }
    public Supplier findByName(String fname)
    {
        IFDBSupplier dbSup = new DBSupplier();
        return dbSup.searchSupplier(fname, true);
    }

      public Supplier findById(String id)
    {
        IFDBSupplier dbSup = new DBSupplier();
        return dbSup.findSupplier(id, true);
    }
      public int updateSupplier(int id, String name, String address, String country, String phone, String email)
      {
          IFDBSupplier dbSup = new DBSupplier();
          Supplier sup = new Supplier();
          sup.setId(id);
          sup.setName(name);
          sup.setAddress(address);
          sup.setCountry(country);
          sup.setPhoneno(phone);
          sup.setEmail(email);
          return  dbSup.updateSupplier(sup);

      }


      public int insertNewSupplier(String name, String address, String country, String phone, String email)
      {
          IFDBSupplier dbSup = new DBSupplier();
          Supplier sup = new Supplier();
//          sup.setId(id);
          sup.setName(name);
          sup.setAddress(address);
          sup.setCountry(country);
          sup.setPhoneno(phone);
          sup.setEmail(email);
          return  dbSup.insertSupplier(sup);

      }


}
